package com.qs.questionnairesurveysystem.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    String message;

    Integer code;

    T data;

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<T>();
        result.code = 200;
        result.message = "success";
        result.data = data;
        return result;
    }

    public static <T> Result<T> error(String message, Integer code) {
        Result<T> result = new Result<T>();
        result.code = code;
        result.message = message;
        result.data = null;
        return result;
    }

}
